<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/25 0025
  Time: 14:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fnt" uri="http://java.sun.com/jsp/jstl/functions" %>
<link rel="stylesheet" type="text/css" href="/manage/css/static/question-type/mymian.css"/>
<!--_footer 作为公共模版分离出去-->
<script src="/manage/js/lib/question-type/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/manage/js/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/manage/css/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/manage/js/lib/laypage/1.2/laypage.js"></script>

<span class="r">共有数据：<strong>${questionCount}</strong> 条</span>
<table class="table table-border table-bordered table-bg">
    <thead>
    <tr>
        <th scope="col" colspan="9">问题列表</th>
    </tr>
    <tr class="text-c">
        <th><input type="checkbox" name="selectAll" value=""></th>
        <th>ID</th>
        <th>题目</th>
        <th>解析</th>
        <th>类别</th>
        <th>操作者</th>
        <th>错题数</th>
        <th width="10">问题选项</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pageInfo.list}" var="question" varStatus="stat">
        <tr class="text-c">
            <td><input type="checkbox" value="${question.id}" name="check"></td>
            <td>${question.id}</td>
            <td>
                <a class="question-title">
                    <p style="display: none">${question.subject}</p>
                    ${fnt:substring(question.subject, 0, 5)}
                    ${fnt:length(question.subject) gt 5?'...':''}
                </a>
            </td>
            <td><a class="question-title">
                <p style="display: none">${question.explain}</p>
                    ${fnt:substring(question.explain, 0, 5)}
                    ${fnt:length(question.explain) gt 5?'...':''}
            </a>
            </td>
            <td>${question.category.categoryName}</td>
            <td>${question.admin.adminAccount}</td>
            <td>${question.falseCount}</td>
            <td>
                 <a href="javascript:;" onclick="answer_update('选项修改','/manage/question/answer-update?id=${question.id}&subject=${question.subject}','1000px;')" class="btn btn-primary radius">
                     选项修改
                 </a>
            </td>
            <td class="td-manage">
                <a title="编辑" href="javascript:;" onclick="question_edit('问题编辑','/manage/question/question-update?id=${question.id}&subject=${question.subject}&explain=${question.explain}','1000px;',)" class="ml-5" style="text-decoration:none">
                    <i class="Hui-iconfont">&#xe6df;</i>
                </a>
                <a title="删除" href="javascript:;" onclick="question_del(${question.id})" class="ml-5" style="text-decoration:none">
                    <i class="Hui-iconfont">&#xe6e2;</i>
                </a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="list-page">
    <a href="/manage/question/question-list-page?pageNum=${pageInfo.prePage}" data="${pageInfo.prePage}">上一页</a>
    <c:forEach items="${pageInfo.navigatepageNums}" var="i">
        <c:if test="${pageInfo.pageNum eq i}" var="isCur">
            <span class="current">${i}</span>
        </c:if>
        <c:if test="${not isCur}">
            <a href="#" data="${i}">${i}</a>
        </c:if>
    </c:forEach>
    <a href="/manage/question/question-list-page?pageNum=${pageInfo.nextPage}" data="${pageInfo.nextPage}">下一页</a>
</div>
<script>
        /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
        /*-增加*/
        function answer_update(title,url,w){
            layer_show(title,url,w);
        }
        function question_edit(title,url,w){
            layer_show(title,url,w);
        }
        //删除问题
        function question_del(id){
           layer.confirm('确定要删除吗?',function (index) {
               var data={id:id};
                $.ajax({
                    url:"/manage/question/deleteQuestion",
                    type:'post',
                    data:data,
                    success:function (data) {
                        $(".ml-5").parent().parent().remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    },
                    error:function (data) {
                        console.log(data.msg);
                    }
                });
           });
        }
        /**/
    $(function () {

        //点击问题标题或者解析，显示具体的内容
        $(".question-title").click(function () {
            var message=$(this).children().html();
            layer.open({
                type: 1,
                area: ['400px'],
                fix: false, //不固定
                maxmin: true,
                shade:0.4,
                title: '信息详情',
                content: '<div>'+message+'</div>'
            });
        });

        //批量选中的效果
        $('input:checkbox[name="selectAll"]').click(function () {
            if($(this).is(':checked')){
                $('input:checkbox').each(function () {
                    $(this).prop("checked",true);
                });
            }else{
                $('input:checkbox').each(function () {
                    $(this).prop("checked",false);
                });
            }
        });
    })
</script>
